<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<h2 class="formHeader" id="resultsFormHeader">Film Search Results</h2>

<form:form method="POST" commandName="checkoutForm"
	action="/film_rental/user/checkout" id="resultsForm">
	<table class="formTable">

		<c:if test="${searchResults.size() > 0}">
			<tr class="formRow" id="resultsHeaderRow">
				<td colspan="2" class="formCell" id="resultsHeaderCell"><h3>Film</h3></td>
				<td class="formCell" id="resultsHeaderCell"><h3>Rating</h3></td>
				<td class="formCell" id="resultsHeaderCell"><h3>Cost</h3></td>
			</tr>
		</c:if>


		<c:if test="${searchResults.size() == 0}">
			<tr class="formRow" id="emptyResultsRow">
				<td class="formCell" id="emptyResultsCell">Your search returned no available films. Try changing your
					search terms to find the film you're looking for.</td>
			</tr>
		</c:if>

		<c:forEach items="${searchResults}" var="film">
			<c:url value="/user/films/listings" var="filmListing">
				<c:param name="id" value="${film.filmId}"></c:param>
			</c:url>
			<tr class="formRow">
				<td class="formCell"><form:checkbox path="filmsToCheckout"
						value="${film.filmId}" />
				<td class="formCell"><a href="${filmListing}"><c:out value="${film.title}"></c:out></a></td>
				<td class="formCell"><c:out value="${film.rating}"></c:out></td>
				<td class="formCell">$<c:out value="${film.rentalRate}"></c:out></td>
			</tr>
		</c:forEach>

		<c:if test="${searchResults.size() > 0}">
			<tr class="formRow">

				<td colspan="4" class="formCell"><input type="submit"
					value="Check out Selected Films" class="formButton"/></td>

			</tr>
		</c:if>

	</table>
</form:form>
